package com.clps.algorithm.chapter07.面试题42最近请求次数;

import java.util.LinkedList;
import java.util.Queue;

/**
 *
 */
public class demo01 {

    public static void main(String[] args) {

    }


}

class  RecentCounter{
    private Queue<Integer> times;
    private int windowSize;

    public RecentCounter() {
        times = new LinkedList<>();
        windowSize = 3000;
    }

    public int ping(int t){
        times.offer(t);
        while (times.peek()+windowSize<t){
            times.poll();
        }
        return times.size();
    }
}
